﻿Imports System.Data.SqlClient

Public Class members_home
    Inherits System.Web.UI.Page
    Private objrd As SqlDataReader = Nothing
    Private objfind As New GetData
    Private sSQL As String
    Private ps As New PreparedStatement(sSQL)
    Private userId As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If (Session("uid") <> Nothing And Session("uid") <> "") Then
            userId = Session("uid")
            Dim str, strErr As String
            strErr = ""
            If (userId <> Nothing) Then
                sSQL = "select * from member_info where member_id = @userId and lang_flag = 'zh'"
                ps.addParameter("userId", userId)
                ps.strSql = sSQL
                Dim conn As SqlConnection = objfind.getConn()

                objrd = objfind.dr(ps, strErr, conn, objrd)
                If (objrd.Read()) Then
                    str = objrd.Item("member_name")
                    str += "，"
                    userName.InnerHtml = str
                End If
                sSQL = "select count(*) as cnum from product_info pi join merchant mm on pi.company_id=mm.company_id where mm.owner_id =@userId and pi.lang_flag='zh';"
                ps.strSql = sSQL
                ps.addParameter("userId", userId)
                objrd = objfind.dr(ps, strErr, conn, objrd)
                Dim strNum As String
                If (objrd.Read()) Then
                    strNum = objrd.Item("cnum")
                    supplyNum.InnerHtml = strNum
                End If
                sSQL = "select count(*) as cnum from purchase pi join merchant mm on pi.company_id=mm.company_id where mm.owner_id =@userId and pi.lang_flag='zh';"
                ps.strSql = sSQL
                ps.addParameter("userId", userId)
                objrd = objfind.dr(ps, strErr, conn, objrd)
                Dim strPurchaseNum As String
                If (objrd.Read()) Then
                    strPurchaseNum = objrd.Item("cnum")
                    purchaseNum.InnerHtml = strPurchaseNum
                End If
                objfind.closeConn(conn)

            Else
                userName.InnerHtml = "无该用户"
                supplyNum.InnerHtml = "0"
                purchaseNum.InnerHtml = "0"
            End If
        Else
            Response.Redirect("../cn_login.aspx")
        End If
    End Sub

End Class